package com.weex.app;

import android.app.Application;

import com.abe.libhttp.utils.BaseHttpUtils;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.weex.app.extend.FrescoImageAdapter;
import com.weex.app.extend.ImageAdapter;
import com.weex.app.extend.WXEventModule;
import com.alibaba.weex.plugin.loader.WeexPluginContainer;
import com.weex.app.module.http.UploadFileModule;
import com.weex.app.module.photo.PhotoModule;
import com.weex.app.module.signature.SignatureModule;
import com.weex.app.module.tool.ToolModule;
import com.weex.app.util.AppConfig;
import com.taobao.weex.InitConfig;
import com.taobao.weex.WXSDKEngine;
import com.taobao.weex.common.WXException;

public class WXApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        CrashHandler crashHandler = CrashHandler.getInstance();
        crashHandler.init(this);
        Fresco.initialize(this);
        BaseHttpUtils.init(this);//网络库使用
        WXSDKEngine.addCustomOptions("appName", "WXSample");
        WXSDKEngine.addCustomOptions("appGroup", "WXApp");
        WXSDKEngine.initialize(this,
                new InitConfig
                        .Builder()
                        .setImgAdapter(new ImageAdapter())
                        .build()
        );
        try {
            WXSDKEngine.registerModule("event", WXEventModule.class);
            WXSDKEngine.registerModule("tool", ToolModule.class);
            WXSDKEngine.registerModule("signature", SignatureModule.class);
            WXSDKEngine.registerModule("photo", PhotoModule.class);
            WXSDKEngine.registerModule("upload", UploadFileModule.class);
        } catch (WXException e) {
            e.printStackTrace();
        }
        AppConfig.init(this);
        WeexPluginContainer.loadAll(this);
    }
}
